package de.bloxel.core;

import com.jme3.asset.AssetManager;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Sphere;
import com.jme3.system.AppSettings;

/**
 * Draws a cross hair directly in the given guiNode
 * 
 * @author Nice2000
 */
public class CrossHair {
  public CrossHair(final Node guiNode, BitmapFont guiFont, final AssetManager assetManager, final AppSettings appSettings) {
    guiNode.detachAllChildren();
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    final BitmapText ch = new BitmapText(guiFont, false);
    ch.setSize(guiFont.getCharSet().getRenderedSize() * 2);
    ch.setText("+"); // crosshairs
    ch.setLocalTranslation(
    // center
        appSettings.getWidth() / 2 - guiFont.getCharSet().getRenderedSize() / 3 * 2, appSettings.getHeight() / 2 + ch.getLineHeight() / 2, 0);
    guiNode.attachChild(ch);
  }

  /**
   * Creates a red Sphere.
   * 
   * @param assetManager
   *          to load assets
   * @return a red sphere to mark something
   */
  public Geometry getMarker(final AssetManager assetManager) {
    final Sphere sphere = new Sphere(30, 30, 0.2f);
    final Geometry mark = new Geometry("Marker", sphere);
    final Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
    mark_mat.setColor("m_Color", ColorRGBA.Red);
    mark.setMaterial(mark_mat);
    return mark;
  }
}
